import {
  HTTP
} from "../utils/http-promise"
class KeywordModel extends HTTP {
  maxLength = 10
  getHistory() {
    return wx.getStorageSync('q') || []
  }
  addToHistory(keyword) {
    let words = this.getHistory()
    const has = words.includes(keyword)
    if (!has) {
      if (words.length >= this.maxLength) {
        words.pop()
      }
      words.unshift(keyword)
      wx.setStorageSync('q', words)
    }
  }

  getHot() {
    return this.request({
      url: 'book/hot_keyword'
    })
  }
}
export {
  KeywordModel
}